﻿<UserControl x:Class="ThumbGen.ProfileSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:ThumbGen"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/CommonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <GroupBox Style="{StaticResource GroupBoxStyle}" Header="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}, Path=HeaderText}">
        <Grid Loaded="StackPanel_Loaded" MinWidth="80">
            <!--<Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>-->
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <ComboBox Grid.Column="0" VerticalAlignment="Center" SelectionChanged="ComboBox_SelectionChanged"
                              IsSynchronizedWithCurrentItem="True" x:Name="ProfilesCombo"
                              SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}, Path=Manager.SelectedProfile}"
                              ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}, Path=Manager.Profiles}"
                              DisplayMemberPath="ProfileName" 
                              ToolTip="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}, Path=Manager.SelectedProfile.ProfileName}">
                    <ComboBox.Resources>
                        <Style TargetType="ComboBoxItem">
                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        </Style>
                    </ComboBox.Resources>
                </ComboBox>
                <Button VerticalAlignment="Center" Click="RefreshProfiles_Click" ToolTip="Refresh the profiles list" Tag="{Binding ElementName=ProfilesCombo,Path=SelectedItem, Mode=OneWay}">
                    <Image Source="/images/refresh.png" Width="16" Height="16" VerticalAlignment="Center"/>
                </Button>
            
                <Button Margin="1" VerticalAlignment="Center" Click="SaveProfile_Click" ToolTip="Save current profile to disk" HorizontalContentAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/images/save.png" VerticalAlignment="Center" Width="16" Height="16"/>
                        <!--<TextBlock Margin="3 0 0 0" VerticalAlignment="Center" Text="Save"/>-->
                    </StackPanel>
                </Button>
                <Button Margin="1" VerticalAlignment="Center" Click="AddProfile_Click" ToolTip="Make a new profile from current settings" HorizontalContentAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/images/add.png" VerticalAlignment="Center" Width="16" Height="16"/>
                        <!--<TextBlock Margin="3 0 0 0" VerticalAlignment="Center" Text="Save as"/>-->
                    </StackPanel>
                </Button>
                <Button Margin="1" x:Name="DeleteProfileButton" VerticalAlignment="Center" Click="DeleteProfile_Click" ToolTip="Delete the current profile" HorizontalContentAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/images/del.png" VerticalAlignment="Center" Width="16" Height="16"/>
                        <!--<TextBlock Margin="3 0 0 0" VerticalAlignment="Center" Text="Delete"/>-->
                    </StackPanel>
                </Button>
            </StackPanel>
        </Grid>
    </GroupBox>
</UserControl>
